import { registerClass } from "../../../cfw/tools/class_decorator";
import { BaseShare } from "../../core/share/BaseShare";
import { ResultState, SDKShareParam } from "../../SDKDefine";


@registerClass('KSShare')
export default class KSShare extends BaseShare {

  
    open(param: SDKShareParam): void {
        this.callback = param.callback;
        let data = this.data[param.index]
        console.log(' share data ', data, param.videoPath, 'index ', param.index)
        if (param.videoPath && data.extra) {
            data.extra.videoPath = param.videoPath;
        }
        data.success = () => {
            console.log('分享成功');
            if (this.callback) {
                this.callback(ResultState.YES);
            }
        }
        data.fail = (e: any) => {
            console.log('分享失败');
            if (this.callback) {
                this.callback(ResultState.NO);
            }
        }
        this.sdk.shareAppMessage(data)
    }

}